package com.bw.zg2.view.adapter

import android.content.Context
import android.graphics.Color
import android.widget.TextView
import com.bw.zg2.R
import com.bw.zg2.bean.GoodsTypeBean
import com.zhy.adapter.recyclerview.CommonAdapter
import com.zhy.adapter.recyclerview.base.ViewHolder

/**
 *
 * @ClassName: TypeLeftAdapter
 * @Description: java类作用描述
 * @Author: zhangyanchao
 * @CreateDate: 2024/9/21 9:23 AM
 * @Version: 1.0
 */
class TypeLeftAdapter(context: Context?, layoutId: Int, datas: List<GoodsTypeBean>) :
    CommonAdapter<GoodsTypeBean>(context, layoutId, datas) {
    override fun convert(holder: ViewHolder?, t: GoodsTypeBean?, position: Int) {

        val tv = holder?.getView<TextView>(R.id.tv_type)
        tv?.text = t?.category_name

        //根据选中状态，设置背景颜色
        if (t?.isCheck == true) {
            tv?.setBackgroundColor(Color.RED)
        } else {
            tv?.setBackgroundColor(Color.GRAY)
        }
    }
}